﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ProjectManApi.Extensions;
using BusinessEntity.Assets;
using BusinessEntity;
using BusinessEntity.QuerryEntity;
using Microsoft.AspNetCore.Authorization;
using Nacos.AspNetCore;
using learun.util;
using System.Net.Http;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System.IO;
using NLog;
using System.Text;
using System.Net.Http.Headers;
using System.Net;
using System.Web;
using BusinessRule;
using System.Dynamic;
using Newtonsoft.Json.Converters;
using BusinessEntity.Warning;
using APICommond;
using Newtonsoft.Json.Linq;

namespace ProjectManApi.Controllers
{
    public class AssetsController : MvcControllerBase
    {

        #region "测试"

        private readonly INacosServerManager _serverManager;
        public AssetsController(INacosServerManager serverManager) : base(serverManager)
        {
            _serverManager = serverManager;

        }

        //private readonly IHostingEnvironment _hostingEnvironment;


        //public AssetsController(IHostingEnvironment hostingEnvironment)
        //{
        //     _hostingEnvironment = hostingEnvironment;
        //}
        //[HttpPost]
        //public IActionResult Index()
        //{
        //    return View();
        //}

        //[HttpPost]
        //[AllowAnonymous]
        //public IActionResult Index()
        //{
        //    string userid = GetTokenUserID();
        //    string json = GetUserInfo("2152df82379e4cc3b5acbb75d4ea51ef");
        //    return Success(json);
        //}

        //[HttpPost]
        //public async Task<IActionResult> GetAssetsListAsync(string scid)
        //{
        //    (DataTable, int) SelectTable = await BusinessRule.Assets.GetAssetsList(scid, GetUserId(), null, "id", true, 20, 1);

        //    return Success(SelectTable);

        //}

        //[HttpPost]
        //public async Task<IActionResult> GetMainListAsync(MainListEntity entity)
        //{
        //    (DataTable, int) SelectTable = await BusinessRule.Assets.GetMainList(entity);

        //    return Success(SelectTable);

        //}
        #endregion

        #region "数据字典"
        /// <summary>
        /// 获取字典类型
        /// </summary>
        /// <param name="item">字典类型（获取全部时传空）</param>
        /// <param name="Size">每页行数</param>
        /// <param name="Current">第几页</param>
        /// <returns>数据字典列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetItems(string item, int Size = 10, int Current = 1)
        {
            try
            {
                (DataTable, int) datetable = await BusinessRule.Assets.GetItems(item, Size, Current);
                Page pa = new Page();
                pa.records = datetable.Item1;
                pa.total = datetable.Item2;
                return Success(pa);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增字典类型
        /// </summary>
        /// <param name="zd">字典类型实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertItem([FromBody] ZC_ZDLX zd)
        {
            try
            {
                await BusinessRule.Assets.InsertItem(zd);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据字典类型和字典编号获取字典值
        /// </summary>
        /// <param name="Item">字典类型</param>
        /// <param name="Flag">编号</param>
        /// <returns>字典值</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_SJZDByID(string Item, string Flag)
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_SJZDByID(Item, Flag);
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据数据字典类型获取数据字典列表
        /// </summary>
        /// <param name="Item">字典类型</param>
        /// <returns>数据字典列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_SJZDTable(string Item)
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_SJZDTable(Item);
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据数据字典类型获取数据字典列表
        /// </summary>
        /// <param name="Item">字典类型</param>
        /// <returns>数据字典列表树</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_SJZD(string Item)
        {
            try
            {
                List<ZC_SJZDList> list = await BusinessRule.Assets.GetZC_SJZD(Item);
                return Success(list);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 保存数据字典
        /// </summary>
        /// <param name="zd">数据字典实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]

        public async Task<IActionResult> InsertZC_SJZD(ZC_SJZD zd)
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_SJZDTable(zd.Item);
                DataRow[] rows = table.Select("Flag='" + zd.Flag + "'");
                if (rows.Length > 0)
                {
                    return Fail("数据重复！" + zd.Flag);
                }
                await BusinessRule.Assets.InsertZC_SJZD(zd);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 更新数据字典
        /// </summary>
        /// <param name="zd">字典实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_SJZD(ZC_SJZD zd)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_SJZD(zd);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据数据字典类型和编号删除数据字典
        /// </summary>
        /// <param name="Item">类型</param>
        /// <param name="Flag">编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_SJZD(String Item, string Flag)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_SJZD(Item, Flag);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion

        #region "系统设置"
        /// <summary>
        /// 获取基本设置
        /// </summary>
        /// <returns>返回基本设置</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_JBSZ()
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_JBSZ();
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增基本设置
        /// </summary>
        /// <param name="jb">基本设置实体类</param>
        /// <returns>返回执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_JBSZ(ZC_JBSZ jb)
        {
            try
            {
                await BusinessRule.Assets.InsertZC_JBSZ(jb);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 获取卡片及变动设置
        /// </summary>
        /// <returns>返回设置信息</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_KPSZ()
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_KPSZ();
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 保存卡片及变动设置
        /// </summary>
        /// <param name="jb">卡片设置实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_KPSZ(ZC_KPSZ jb)
        {
            try
            {
                await BusinessRule.Assets.InsertZC_KPSZ(jb);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 获取折旧设置
        /// </summary>
        /// <returns>返回折旧设置信息</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZJSZ()
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_ZJSZ();
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 保存折旧设置
        /// </summary>
        /// <param name="jb">折旧设置实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZJSZ(ZC_ZJSZ jb)
        {
            try
            {
                await BusinessRule.Assets.InsertZC_ZJSZ(jb);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 获取结账设置
        /// </summary>
        /// <returns>返回结账设置</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_JZSZ()
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_JZSZ();
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增结账设置
        /// </summary>
        /// <param name="jb">结账设置实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_JZSS(ZC_JZSS jb)
        {
            try
            {
                await BusinessRule.Assets.InsertZC_JZSS(jb);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion 

        #region "公用"

        /// <summary>
        /// 根据单位编号和类型生成代码
        /// </summary>
        /// <param name="Dwdm">单位代码</param>
        /// <param name="Lx">类型</param>
        /// <returns>代码</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> CreateZCDM(string Dwdm, string Lx)
        {
            try
            {
                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                string zcdm = await BusinessRule.Assets.CreateZCDM(Dwdm, Lx);
                _logger.Log(LogLevel.Info, Success(zcdm).ToJson());
                return Success(zcdm);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }

        #endregion

        #region "资产预算"
        /// <summary>
        /// 获取资产预算
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_Ys([FromQuery] ZC_YSQuerry entity)
        {
            try
            {

                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                entity.UserID = GetUserId();
                entity.DepartID = await GetDepId();
                //entity.DepartID = "('1')";
                (IEnumerable<dynamic>, int) SelectTable = await BusinessRule.Assets.GetZC_Ys(entity);

                List<string> list = new List<string>();
                foreach (dynamic item in SelectTable.Item1)
                {
                    string id = item.id;
                    list.Add(id);
                }

                List<JavaApi.SPSDataItem> spitems = await JavaApi.GetSPStatusJavaAPI(entity.FormCode, GetUserAccount(), list, await GetICApiInfo());
                foreach (dynamic item in SelectTable.Item1)
                {
                    string id = item.id;
                    var spstatus = spitems.Where(ii => ii.businessId == id).FirstOrDefault();

                    item.panguData = GetPanGudData(spstatus, item.spstatus);
                }

                Page pa = new Page();
                pa.records = SelectTable.Item1;
                pa.total = SelectTable.Item2;

                _logger.Log(LogLevel.Info, Success(pa).ToJson());
                return Success(pa);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增资产预算
        /// </summary>
        /// <param name="zc">资产预算实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_Ys([FromBody] BusinessEntity.Assets.YS zc)
        {
            try
            {
                if (zc.ZCYS.Zcdm == "" || zc.ZCYS.Zcdm == null)
                {
                    zc.ZCYS.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.ZCYS.Dwdm, "");
                }
                if (zc.ZCYS.ListID == "")
                {
                    zc.ZCYS.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (zc.ZCYS.Djbh == "" || zc.ZCYS.Djbh == null)
                {
                    zc.ZCYS.Djbh = await BusinessRule.Assets.CreateZCDM(zc.ZCYS.Dwdm, "YS");
                }

                _logger.Log(LogLevel.Info, this.Url.Action() + zc.ToJson());
                if (await JavaApi.UploadFileJavaAPI(zc.ZCYS.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_Ys(zc.ZCYS);
                }
                _logger.Log(LogLevel.Info, Success("成功").ToJson());
                return Success("成功");
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 更新资产预算
        /// </summary>
        /// <param name="zc">资产预算实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_YS([FromBody] BusinessEntity.Assets.YS zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.ZCYS.ListID, zc.File, await GetICApiInfo()))
                {
                    if (zc.ZCYS.Zt == "0")
                    {
                        bool bsp = false;
                        JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                        spl.businessName = "zcys";
                        spl.businessId = zc.ZCYS.ListID;
                        //spl.publicParamKey = "FEE_PROCESS";
                        spl.formCode = zc.File.code;

                        //spl.description.businessNo = zc.ZCYS.ListID;
                        //spl.description.deptName = GetUserDeptName();
                        spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.ZCYS);
                        spl.callbackUrl = "";

                        bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                        if (bsp)
                        {
                            await BusinessRule.Assets.UpdateZC_YS(zc.ZCYS);
                        }
                    }
                    else
                    {

                        await BusinessRule.Assets.UpdateZC_YS(zc.ZCYS);
                    }

                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 删除资产预算
        /// </summary>
        /// <param name="zc">资产预算实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_YS([FromBody] ZC_YS zc)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_YS(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据资产编号获取资产预算
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>资产预算</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_YSByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_YSByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 获取上传的excel表格表页名称
        /// </summary>
        /// <param name="formCollection"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> GetExcelTableName([FromForm] IFormCollection formCollection)
        {
            try
            {
                string rootdir = AppContext.BaseDirectory;
                DirectoryInfo Dir = Directory.GetParent(rootdir);
                string webRootPath = Dir.Parent.Parent.FullName;
                FormFileCollection filelist = (FormFileCollection)formCollection.Files;
                string nfilepath = "";
                foreach (IFormFile file in filelist)
                {
                    String Tpath = "/资产文件/UpLoad/";
                    string name = file.FileName;
                    string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    string FilePath = webRootPath + Tpath;

                    string type1 = Path.GetExtension(name);
                    DirectoryInfo di = new DirectoryInfo(FilePath);

                    if (!di.Exists)
                    {
                        di.Create();
                    }

                    using (FileStream fs = System.IO.File.Create(FilePath + FileName + type1))
                    {
                        // 复制文件
                        file.CopyTo(fs);
                        // 清空缓冲区数据
                        fs.Flush();
                    }
                    nfilepath = FilePath + FileName + type1;
                }
                DataSet ds = APICommond.ImportExcel.GetExcelTableName(nfilepath);
                return Success(ds.Tables[0]);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 导入资产预算
        /// </summary>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> ImportZC_YS([FromForm] IFormCollection formCollection)
        {
            try
            {
                string rootdir = AppContext.BaseDirectory;
                DirectoryInfo Dir = Directory.GetParent(rootdir);
                string webRootPath = Dir.Parent.Parent.FullName;
                FormFileCollection filelist = (FormFileCollection)formCollection.Files;
                string nfilepath = "";
                foreach (IFormFile file in filelist)
                {
                    String Tpath = "/资产文件/UpLoad/";
                    string name = file.FileName;
                    string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    string FilePath = webRootPath + Tpath;

                    string type1 = Path.GetExtension(name);
                    DirectoryInfo di = new DirectoryInfo(FilePath);

                    if (!di.Exists)
                    {
                        di.Create();
                    }

                    using (FileStream fs = System.IO.File.Create(FilePath + FileName + type1))
                    {
                        // 复制文件
                        file.CopyTo(fs);
                        // 清空缓冲区数据
                        fs.Flush();
                    }
                    nfilepath = FilePath + FileName + type1;


                }
                string err = "";
                DataSet ds = APICommond.ImportExcel.GetExcelData(nfilepath, out err);
                if (err != "")
                {
                    return Fail(err);
                }
                List<ImportMsg> listmsg = new List<ImportMsg>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow row = ds.Tables[0].Rows[i];
                    if (Convert.ToString(row[0]).Trim() != "" && Convert.ToString(row[1]).Trim() != "")
                    {
                        ZC_YS ys = new ZC_YS();

                        ys.Kjnd = Convert.ToString(row[0]).Trim();
                        ys.Dwdm = Convert.ToString(row[1]).Trim();
                        ys.Dwmc = Convert.ToString(row[2]).Trim();
                        ys.Bmdm = Convert.ToString(row[3]).Trim();
                        ys.Bmmc = Convert.ToString(row[4]).Trim();
                        ys.Ysdwdm = ys.Dwdm;
                        ys.Ysdwmc = ys.Dwmc;
                        ys.Ysbmdm = ys.Bmdm;
                        ys.Ysbmmc = ys.Bmmc;
                        ys.Ssbmdm = ys.Bmdm;
                        ys.Ssbmmc = ys.Bmmc;
                        ys.Zcdm = Convert.ToString(row[5]).Trim();
                        ys.Zcmc = Convert.ToString(row[6]).Trim();
                        ys.Zclbdm = Convert.ToString(row[7]).Trim();
                        ys.Zclbmc = Convert.ToString(row[8]).Trim();
                        ys.Ggxh = Convert.ToString(row[9]).Trim();
                        ys.Jldw = Convert.ToString(row[10]).Trim();
                        decimal dj = 0;
                        if (decimal.TryParse(row[11].ToString(), out dj))
                        {
                            ys.Ysdjkz = Convert.ToDecimal(row[11]);
                        }
                        else
                        {
                            ImportMsg msg1 = new ImportMsg();
                            msg1.ID = i + 1;
                            msg1.ErrMsg = "第" + (i + 1) + "条数据导入检查未通过，预算单价应该为数字。";
                            msg1.IsSuccess = "false";
                            listmsg.Add(msg1);
                            continue;
                        }
                        decimal sl = 0;
                        if (decimal.TryParse(row[12].ToString(), out sl))
                        {
                            ys.Yszlkz = Convert.ToDecimal(row[12]);
                        }
                        else
                        {
                            ImportMsg msg2 = new ImportMsg();
                            msg2.ID = i + 1;
                            msg2.ErrMsg = "第" + (i + 1) + "条数据导入检查未通过，预算数量应该为数字。";
                            msg2.IsSuccess = "false";
                            listmsg.Add(msg2);
                            continue;
                        }
                        decimal zj = 0;
                        if (decimal.TryParse(row[13].ToString(), out zj))
                        {
                            ys.Yszjkz = Convert.ToDecimal(row[13]);
                        }
                        else
                        {
                            ImportMsg msg3 = new ImportMsg();
                            msg3.ID = i + 1;
                            msg3.ErrMsg = "第" + (i + 1) + "条数据导入检查未通过，预算总价应该为数字。";

                            msg3.IsSuccess = "false";
                            listmsg.Add(msg3);
                            continue;
                        }
                        ys.Cgfsdm = Convert.ToString(row[14]).Trim();
                        ys.Cgfsmc = Convert.ToString(row[15]).Trim();
                        ys.Yt = Convert.ToString(row[16]).Trim();
                        ys.Bz = Convert.ToString(row[17]).Trim();
                        ys.Djbh = await BusinessRule.Assets.CreateZCDM(ys.Dwdm, "YS");
                        DataTable data = await BusinessRule.Assets.GetZCYS(ys.Kjnd, ys.Dwdm, ys.Bmdm, ys.Zcdm, Convert.ToDecimal(ys.Yszlkz), Convert.ToDecimal(ys.Ysdjkz), Convert.ToDecimal(ys.Yszjkz));
                        if (data.Rows.Count > 0)
                        {
                            ImportMsg msg3 = new ImportMsg();
                            msg3.ID = i + 1;
                            msg3.ErrMsg = "第" + (i + 1) + "条数据导入检查未通过，数据已存在。";

                            msg3.IsSuccess = "false";
                            listmsg.Add(msg3);
                            continue;
                        }
                        await BusinessRule.Assets.InsertZC_Ys(ys);
                        ImportMsg msg = new ImportMsg();
                        msg.ID = i + 1;
                        msg.ErrMsg = "";

                        msg.IsSuccess = "true";
                        listmsg.Add(msg);
                    }
                    else
                    {
                        ImportMsg msg = new ImportMsg();
                        msg.ID = i + 1;
                        msg.ErrMsg = "第" + (i + 1) + "条数据导入检查未通过，会计年度或单位代码为空。";

                        msg.IsSuccess = "false";
                        listmsg.Add(msg);

                    }
                }
                return Success(listmsg);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 下载资产预算模板
        /// </summary>
        /// <returns>文件流</returns>
        [HttpGet]
        [AllowAnonymous]
        public IActionResult DownloadZC_YS()
        {

            try
            {
                string rootdir = AppContext.BaseDirectory;
                DirectoryInfo Dir = Directory.GetParent(rootdir);
                string webRootPath = Dir.Parent.Parent.FullName;
                string filePath = webRootPath + "/UpLoad/Template/资产负债表导入模板.xls";
                //string filePath = @"D:\开发\开发文档\三资监管\斜塘确认后产交合同\斜塘确认后产交合同\(斜塘)合同附件.xlsx";
                //string filePath = HttpContext.Current.Server.MapPath("~/") + "FileRoot\\" + "ReportTemplate.xlsx";
                FileStream stream = new FileStream(filePath, FileMode.Open);
                var actionresult = new FileStreamResult(stream, new Microsoft.Net.Http.Headers.MediaTypeHeaderValue("text/xls"));
                actionresult.FileDownloadName = "预算导入模板.xls";
                //Response.ContentLength = res.Length;
                return actionresult;
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
            //return response;
        }

        #endregion

        #region "预算调整"
        /// <summary>
        /// 获取预算调整
        /// </summary>
        /// <param name="entity">查询条件</param>
        /// <returns>预算调整列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_YSTZ([FromQuery] ZC_YSTZQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_YSTZ(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增预算调整
        /// </summary>
        /// <param name="zc">预算调整实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_YsTZ([FromBody] YSTZ tz)
        {
            try
            {
                ZC_YSTZ zc = tz.ZCYSTZ;
                if (zc.Zcdm == "" || zc.Zcdm == null)
                {
                    zc.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Dwdm, "");
                }
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (zc.Djbh == "" || zc.Djbh == null)
                {
                    zc.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Dwdm, "YS");
                }
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, tz.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_YSTZ(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 修改预算调整
        /// </summary>
        /// <param name="zc">预算调整实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_YSTZ([FromBody] YSTZ zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.ZCYSTZ.ListID, zc.File, await GetICApiInfo()))
                {
                    if (zc.ZCYSTZ.Zt == "0")
                    {
                        bool bsp = false;
                        JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                        spl.businessName = "ystz";
                        spl.businessId = zc.ZCYSTZ.ListID;
                        //spl.publicParamKey = "FEE_PROCESS";
                        spl.formCode = zc.File.code;

                        //spl.description.businessNo = zc.ZCYS.ListID;
                        //spl.description.deptName = GetUserDeptName();
                        spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.ZCYSTZ);
                        spl.callbackUrl = "";

                        bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                        if (bsp)
                        {
                            await BusinessRule.Assets.UpdateZC_YSTZ(zc.ZCYSTZ);
                        }
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_YSTZ(zc.ZCYSTZ);
                    }

                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 删除资产预算调整
        /// </summary>
        /// <param name="zc">资产预算调整实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_YSTZ([FromBody] ZC_YSTZ zc)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_YSTZ(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据编号获取资产预算调整详情
        /// </summary>
        /// <param name="Listid">资产预算编号</param>
        /// <returns>资产预算调整详情</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_YSTZByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_YSTZByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 根据编号获取资产预算调整明细
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>资产预算调整明细</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_YSTZMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_YSTZMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 新增预算调整内容
        /// </summary>
        /// <param name="zc">预算调整内容实体类</param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_YSTZMX([FromBody] ZC_YSTZNR zc)
        {
            try
            {
                await BusinessRule.Assets.InsertZC_YSTZMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 修改资产预算调整
        /// </summary>
        /// <param name="zc">预算调整内容实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_YSTZMX([FromBody] ZC_YSTZNR zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_YSTZMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 删除资产预算调整内容
        /// </summary>
        /// <param name="zc">资产预算调整内容实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_YSTZMX([FromBody] ZC_YSTZNR zc)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_YSTZMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion

        #region "采购目录"
        /// <summary>
        /// 查询采购目录
        /// </summary>
        /// <param name="Mlmc">目录名称</param>
        /// <param name="Mldm">目录代码</param>
        /// <param name="Zt">状态</param>
        /// <returns>采购目录列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_CGMLQuerry(string Mlmc = "", string Mldm = "", string Zt = "")
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_CGMLQuerry(Mlmc, Mldm, Zt);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 导入采购目录
        /// </summary>
        /// <param name="formCollection">文件流</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public IActionResult ImportZC_CGML([FromForm] IFormCollection formCollection)
        {
            try
            {
                string rootdir = AppContext.BaseDirectory;
                DirectoryInfo Dir = Directory.GetParent(rootdir);
                string webRootPath = Dir.Parent.Parent.FullName;
                FormFileCollection filelist = (FormFileCollection)formCollection.Files;

                foreach (IFormFile file in filelist)
                {
                    String Tpath = "/UpLoad/";
                    string name = file.FileName;
                    string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    string FilePath = webRootPath + Tpath;
                    string type1 = Path.GetExtension(name);
                    DirectoryInfo di = new DirectoryInfo(FilePath);

                    if (!di.Exists)
                    {
                        di.Create();
                    }

                    using (FileStream fs = System.IO.File.Create(FilePath + FileName + type1))
                    {
                        // 复制文件
                        file.CopyTo(fs);
                        // 清空缓冲区数据
                        fs.Flush();
                    }

                }

                return Success("导入成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 根据父级编号查询资产类别
        /// </summary>
        /// <param name="Parentdm">父编号</param>
        /// <param name="Cgml">采购目录</param>
        /// <param name="Current">当前页</param>
        /// <param name="Size">每页行数</param>
        /// <returns>资产类别列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_CGMLByParent(string Parentdm = "", string Cgml = "", int Current = 0, int Size = 10)
        {
            try
            {
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_CGMLByParent(Parentdm, Cgml, Current, Size);
                Page pa = new Page();
                pa.records = SelectTable.Item1;
                pa.total = SelectTable.Item2;
                return Success(pa);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 查询资产大类
        /// </summary>
        /// <returns>资产大类列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCDL()
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCDL();

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        //    [HttpGet]
        //[AllowAnonymous]
        //public async Task<IActionResult> GetZC_CGMLAll()
        //{
        //    try
        //    {
        //        DataTable SelectTable = await BusinessRule.Assets.GetZC_CGMLAll();


        //        return Success(SelectTable);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Fail(ex.Message);
        //    }
        //}
        /// <summary>
        /// 查询所有的资产类别
        /// </summary>
        /// <param name="Zclb">资产类别</param>
        /// <returns>资产类别列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_CGMLAll(string Zclb)
        {
            try
            {
                List<CGMLTree> SelectTable = await BusinessRule.Assets.GetZC_CGMLAllTree(Zclb);


                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据资产大类查询资产类别
        /// </summary>
        /// <param name="Dldm">资产大类</param>
        /// <returns>资产类别列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_CGML(string Dldm)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_CGML(Dldm);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 根据资产大类查询资产类别
        /// </summary>
        /// <param name="Dldm">资产大类</param>

        /// <returns>资产类别列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_CGMLByDLDM(string Dldm)
        {
            try
            {
                List<CGMLTree> SelectTable = await BusinessRule.Assets.GetZC_CGMLByDLDM(Dldm);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增资产类别
        /// </summary>
        /// <param name="zc">资产类别实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_CGML([FromBody] ZC_CGML zc)
        {
            try
            {
                //DataTable SelectTable = await BusinessRule.Assets.GetZC_CGMLAll(zc.Dldm);
                //DataRow[] rows = SelectTable.Select("Mldm='" + zc.Mldm + "'");
                //if (rows.Length > 0)
                //{
                //    return Fail("目录代码已存在，请重新输入！");
                //}

                await BusinessRule.Assets.InsertZC_CGML(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 修改资产类别
        /// </summary>
        /// <param name="zc">实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_CGML([FromBody] ZC_CGML zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_CGML(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 删除资产类别
        /// </summary>
        /// <param name="Mldm">类别代码</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_CGML(string Mldm)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_CGML(Mldm);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion

        #region "资产配置"
        /// <summary>
        /// 查询资产购置列表
        /// </summary>
        /// <param name="entity">查询条件</param>
        /// <returns>购置列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPZ([FromQuery] ZC_ZCPZQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                entity.DepartID = "('1')";
                //entity.DepartID = await GetDepId();
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCPZ(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> SaveZCPZ([FromBody] ZCPZ zc)
        {
            try
            {

                if (zc.Zcpz.Djbh == "" || zc.Zcpz.Djbh == null)
                {
                    zc.Zcpz.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcpz.Dwdm, "PZ");
                }
                string listid = "";
                if (zc.Zcpz.ListID == "")
                {
                    if (zc.Zcpz.ListID == "")
                    {
                        zc.Zcpz.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcpz.ListID, zc.File, await GetICApiInfo()))
                    {
                        listid = await BusinessRule.Assets.InsertZC_ZCPZ(zc.Zcpz);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcpz.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcpz.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "jzcys";
                            spl.businessId = zc.Zcpz.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.ZCYS.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcpz);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCPZ(zc.Zcpz);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCPZ(zc.Zcpz);
                        }



                    }
                }
                foreach (ZC_ZCPZMX mx in zc.MxList)
                {
                    if (mx.ListID == "")
                    {
                        mx.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                        mx.PzID = listid;
                        //zc.Zcpz.Zcsgze = mx.Sgzj + zc.Zcpz.Zcsgze;
                        //zc.Zcpz.Zcysze = mx. + zc.Zcpz.Zcsgze;
                        await BusinessRule.Assets.InsertZC_ZCPZMX(mx);
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_ZCPZMX(mx);
                    }
                }
                await BusinessRule.Assets.UpdateZC_ZCPZ(zc.Zcpz);
                return Success(listid);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增资产购置
        /// </summary>
        /// <param name="zc">购置实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCPZ([FromBody] ZCPZ zc)
        {
            try
            {
                if (zc.Zcpz.ListID == "")
                {
                    zc.Zcpz.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (zc.Zcpz.Djbh == "" || zc.Zcpz.Djbh == null)
                {
                    zc.Zcpz.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcpz.Dwdm, "YS");
                }
                string listid = "";
                if (await JavaApi.UploadFileJavaAPI(zc.Zcpz.ListID, zc.File, await GetICApiInfo()))
                {
                    listid = await BusinessRule.Assets.InsertZC_ZCPZ(zc.Zcpz);
                }
                return Success(listid);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 修改资产购置
        /// </summary>
        /// <param name="zc">实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCPZ([FromBody] ZCPZ zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcpz.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCPZ(zc.Zcpz);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 删除资产购置
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCPZ(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCPZ(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据编号查询资产购置
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>资产购置详情</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPZByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPZByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }

        /// <summary>
        /// 根据编号查询资产购置
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>资产购置详情</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZCPZByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPZByID(Listid);
                DataTable ysid = await BusinessRule.Assets.GetZC_PZYYYS(Listid);
                DataTable pzmx = await BusinessRule.Assets.GetZC_ZCPZMX(Listid);
                ZCGZ gz = new ZCGZ();
                gz.Zcpz = APICommond.DataTableToList.GetEntity<ZC_ZCPZ>(SelectTable);
                gz.yslist = APICommond.DataTableToList.GetEntities<ZC_YS>(ysid) as List<ZC_YS>;
                gz.Mxlist = APICommond.DataTableToList.GetEntities<ZC_ZCPZMX>(pzmx) as List<ZC_ZCPZMX>;
                return Success(gz, true);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 根据购置单编号查询预算信息
        /// </summary>
        /// <param name="Pzid">购置单编号</param>
        /// <returns>预算信息</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_PZYYYS(string Pzid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_PZYYYS(Pzid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 根据预算编号查询购置信息
        /// </summary>
        /// <param name="Listid">预算编号</param>
        /// <returns>购置信息</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPZByYSID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPZByYsID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 根据购置编号查询购置明细
        /// </summary>
        /// <param name="Listid">购置单编号</param>
        /// <returns>购置明细列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPZMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPZMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 根据编号查询购置明细
        /// </summary>
        /// <param name="Listid">购置明细编号</param>
        /// <returns>购置明细详情</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPZMXByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPZMXByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 新增购置明细
        /// </summary>
        /// <param name="zc">购置明细实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCPZMX([FromBody] ZC_ZCPZMX zc)
        {
            try
            {

                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }

                await BusinessRule.Assets.InsertZC_ZCPZMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 根据预算编号新增资产购置明细
        /// </summary>
        /// <param name="IDs">预算编号数组</param>
        /// <param name="Pzid">购置单编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_PZMX(string[] IDs, string Pzid)
        {
            try
            {

                await BusinessRule.Assets.InsertZC_PZMX(IDs, Pzid);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        /// <summary>
        /// 修改资产购置明细
        /// </summary>
        /// <param name="zc">资产购置明细实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCPZMX([FromBody] ZC_ZCPZMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCPZMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据预算编号删除资产购置明细
        /// </summary>
        /// <param name="ysid">预算编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCPZMXBYYSID(string ysid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCPZMXBYYSID(ysid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 删除资产购置明细
        /// </summary>
        /// <param name="zc">实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCPZMX([FromBody] ZC_ZCPZMX zc)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCPZMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据购置明细编号删除购置明细
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCPZMXBYID(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCPZMXBYID(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 分局购置编号生成卡片
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> CreateCard([FromBody] string Listid)
        {
            try
            {
                await BusinessRule.Assets.CreateCard(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 查询未入库资产
        /// </summary>
        /// <param name="entity">查询条件</param>
        /// <returns>未入库资产列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetWrkzc([FromQuery] ZC_ZCPZQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetWrkzc(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据编号查询未入库资产
        /// </summary>
        /// <param name="Listid">编号</param>
        /// <returns>详情</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetWrkzcByID(string Listid)
        {
            try
            {

                DataTable SelectTable = await BusinessRule.Assets.GetWrkzcByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion

        #region "资产卡片"
        /// <summary>
        ///查询资产卡片
        /// </summary>
        /// <param name="entity">查询条件</param>
        /// <returns>资产卡片列表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCKP([FromQuery] ZC_ZCKPQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                entity.DepartID = "('1')";
                //entity.DepartID = await GetDepId();
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCKP(entity);
                Page pa = new Page();
                pa.records = SelectTable.Item1;
                pa.total = SelectTable.Item2;
                return Success(pa);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 新增资产卡片
        /// </summary>
        /// <param name="zc">实体类</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCKP([FromBody] ZCKP zc)
        {
            try
            {
                if (zc.Zckp.ListID == "")
                {
                    zc.Zckp.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                    if (zc.Zckp.Zcdm == "" || zc.Zckp.Zcdm == null)
                    {
                        zc.Zckp.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zckp.Dwdm, "");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zckp.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCKP(zc.Zckp);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zckp.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zckp.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zckp.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.ZCYS.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zckp);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCKP(zc.Zckp);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCKP(zc.Zckp);
                        }
                    }
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCKP([FromBody] ZCKP zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zckp.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCKP(zc.Zckp);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCKP([FromBody] ZC_ZCKP zc)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCKP(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCKPByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCKPByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        #endregion

        #region "资产卡片设施"
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_KPSS(String Zcdm)
        {
            try
            {

                DataTable SelectTable = await BusinessRule.Assets.GetZC_KPSS(Zcdm);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_KPSS([FromBody] ZC_KPSS zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_KPSS(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_KPSS([FromBody] ZC_KPSS zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_KPSS(zc);
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_KPSS(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_KPSS(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_KPSSByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_KPSSByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        #endregion

        #region "土地房屋资产入库"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZCRKALL([FromQuery] ZC_RKQuerry zc)
        {
            try
            {
                zc.UserID = GetUserId();
                //zc.DepartID = await GetDepId();
                zc.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZCRKALL(zc);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_RKZT([FromBody] ZC_RKZT zt)
        {
            try
            {
                await BusinessRule.Assets.UpdateZT(zt.listid, zt.dldm == null ? zt.zcdl : zt.dldm, zt.zt);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKJ([FromQuery] ZC_ZCRKQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCRKJ(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKJ([FromBody] ZCRKJ zc)
        {
            try
            {
                if (zc.Zcrk.ListID == "")
                {
                    if (zc.Zcrk.Zcdm == "" || zc.Zcrk.Zcdm == null)
                    {
                        zc.Zcrk.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zcrk.Dwdm, "");
                    }
                    if (zc.Zcrk.ListID == "")
                    {
                        zc.Zcrk.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (zc.Zcrk.Djbh == "" || zc.Zcrk.Djbh == null)
                    {
                        zc.Zcrk.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcrk.Dwdm, "RK");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrk.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCRKJ(zc.Zcrk);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrk.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcrk.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zcrk.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.ZCYS.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrk);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCRKJ(zc.Zcrk);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCRKJ(zc.Zcrk);
                        }

                    }

                }



                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKJ([FromBody] ZCRKJ zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcrk.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCRKJ(zc.Zcrk);
                }
                if (zc.Zcrk.Zt == "0")
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "zcrk";
                    spl.businessId = zc.Zcrk.ListID;
                    //spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = zc.File.formCode;

                    //spl.description.businessNo = zc.ZCYS.ListID;
                    //spl.description.deptName = GetUserDeptName();
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrk);
                    spl.callbackUrl = "";

                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKJ(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKJ(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKJByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKJByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKMX([FromBody] ZC_ZCRKMX zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCRKMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKMX([FromBody] ZC_ZCRKMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCRKMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKMX([FromBody] ZC_ZCRKMX zc)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        #endregion

        #region "通用设备资产入库"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKS([FromQuery] ZC_ZCRKQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCRKS(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKS([FromBody] ZCRKS zc)
        {
            try
            {

                if (zc.Zcrk.ListID == "")
                {
                    if (zc.Zcrk.Zcdm == "" || zc.Zcrk.Zcdm == null)
                    {
                        zc.Zcrk.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zcrk.Dwdm, "");
                    }
                    if (zc.Zcrk.ListID == "")
                    {
                        zc.Zcrk.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (zc.Zcrk.Djbh == "" || zc.Zcrk.Djbh == null)
                    {
                        zc.Zcrk.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcrk.Dwdm, "RK");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrk.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCRKS(zc.Zcrk);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrk.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcrk.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zcrk.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description = zc.Zcrk.ListID;
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrk);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCRKS(zc.Zcrk);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCRKS(zc.Zcrk);
                        }

                    }

                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKS([FromBody] ZCRKS zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcrk.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCRKS(zc.Zcrk);
                }
                if (zc.Zcrk.Zt == "0")
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "zcrk";
                    spl.businessId = zc.Zcrk.ListID;
                    //spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = zc.File.formCode;

                    //spl.description = zc.Zcrk.ListID;
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrk);
                    spl.callbackUrl = "";

                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKS(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKS(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKSByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKSByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }



        #endregion

        #region "专用设备资产入库"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKZ([FromQuery] ZC_ZCRKQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCRKZ(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKZ([FromBody] ZCRKZ zc)
        {
            try
            {
                if (zc.Zcrkz.ListID == "")
                {
                    if (zc.Zcrkz.Zcdm == "" || zc.Zcrkz.Zcdm == null)
                    {
                        zc.Zcrkz.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zcrkz.Dwdm, "");
                    }
                    if (zc.Zcrkz.ListID == "")
                    {
                        zc.Zcrkz.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (zc.Zcrkz.Djbh == "" || zc.Zcrkz.Djbh == null)
                    {
                        zc.Zcrkz.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcrkz.Dwdm, "RK");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrkz.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCRKZ(zc.Zcrkz);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrkz.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcrkz.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zcrkz.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description = zc.Zcrkz.ListID;
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrkz);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCRKZ(zc.Zcrkz);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCRKZ(zc.Zcrkz);
                        }
                    }

                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKZ([FromBody] ZCRKZ zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcrkz.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCRKZ(zc.Zcrkz);
                }
                if (zc.Zcrkz.Zt == "0")
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "zcrk";
                    spl.businessId = zc.Zcrkz.ListID;
                    //spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = zc.File.formCode;

                    //spl.description = zc.Zcrkz.ListID;
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrkz);
                    spl.callbackUrl = "";

                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKZ(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKZ(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKZByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKZByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }



        #endregion

        #region "文物资产入库"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKW([FromQuery] ZC_ZCRKQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCRKW(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKW([FromBody] ZCRKW zc)
        {
            try
            {
                if (zc.Zcrkw.ListID == "")
                {
                    if (zc.Zcrkw.Zcdm == "" || zc.Zcrkw.Zcdm == null)
                    {
                        zc.Zcrkw.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zcrkw.Dwdm, "");
                    }
                    if (zc.Zcrkw.ListID == "")
                    {
                        zc.Zcrkw.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (zc.Zcrkw.Djbh == "" || zc.Zcrkw.Djbh == null)
                    {
                        zc.Zcrkw.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcrkw.Dwdm, "RK");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrkw.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCRKW(zc.Zcrkw);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrkw.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcrkw.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zcrkw.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.Zcrkw.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrkw);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCRKW(zc.Zcrkw);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCRKW(zc.Zcrkw);
                        }

                    }

                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKW([FromBody] ZCRKW zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcrkw.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCRKW(zc.Zcrkw);
                }
                if (zc.Zcrkw.Zt == "0")
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "zcrk";
                    spl.businessId = zc.Zcrkw.ListID;
                    //spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = zc.File.formCode;

                    //spl.description.businessNo = zc.Zcrkw.ListID;
                    //spl.description.deptName = GetUserDeptName();
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrkw);
                    spl.callbackUrl = "";

                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKW(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKW(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKWByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKWByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }



        #endregion

        #region "图书档案资产入库"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKD([FromQuery] ZC_ZCRKQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCRKD(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKD([FromBody] ZCRKD zc)
        {
            try
            {
                if (zc.Zcrkd.ListID == "")
                {
                    if (zc.Zcrkd.Zcdm == "" || zc.Zcrkd.Zcdm == null)
                    {
                        zc.Zcrkd.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zcrkd.Dwdm, "");
                    }
                    if (zc.Zcrkd.ListID == "")
                    {
                        zc.Zcrkd.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (zc.Zcrkd.Djbh == "" || zc.Zcrkd.Djbh == null)
                    {
                        zc.Zcrkd.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcrkd.Dwdm, "RK");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrkd.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCRKD(zc.Zcrkd);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrkd.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcrkd.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zcrkd.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.Zcrkd.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrkd);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCRKD(zc.Zcrkd);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCRKD(zc.Zcrkd);
                        }
                    }

                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKD([FromBody] ZCRKD zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcrkd.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCRKD(zc.Zcrkd);
                }
                if (zc.Zcrkd.Zt == "0")
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "zcrk";
                    spl.businessId = zc.Zcrkd.ListID;
                    //spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = zc.File.formCode;

                    //spl.description.businessNo = zc.Zcrkd.ListID;
                    //spl.description.deptName = GetUserDeptName();
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrkd);
                    spl.callbackUrl = "";

                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKD(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKD(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKDByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKDByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }



        #endregion

        #region "家具资产入库"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKY([FromQuery] ZC_ZCRKQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCRKY(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCRKY([FromBody] ZCRKY zc)
        {
            try
            {
                if (zc.Zcrky.ListID == "")
                {
                    if (zc.Zcrky.Zcdm == "" || zc.Zcrky.Zcdm == null)
                    {
                        zc.Zcrky.Zcdm = await BusinessRule.Assets.CreateZCDM(zc.Zcrky.Dwdm, "");
                    }

                    zc.Zcrky.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                    if (zc.Zcrky.Djbh == "" || zc.Zcrky.Djbh == null)
                    {
                        zc.Zcrky.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcrky.Dwdm, "RK");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrky.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCRKY(zc.Zcrky);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcrky.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcrky.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcrk";
                            spl.businessId = zc.Zcrky.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.Zcrky.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcrky);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCRKY(zc.Zcrky);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCRKY(zc.Zcrky);
                        }
                    }
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCRKY([FromBody] ZCRKY zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcrky.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCRKY(zc.Zcrky);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCRKY(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCRKY(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCRKYByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCRKYByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }



        #endregion

        #region "资产领用"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCLY([FromQuery] ZC_ZCLYQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCLY(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetKLZC([FromQuery] LYZCQuerry querry)
        {
            try
            {
                querry.UserID = GetUserId();
                querry.DepartID = await GetDepId();
                querry.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetKLZC(querry);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetKLZCByID(string Listid)
        {
            try
            {

                DataTable SelectTable = await BusinessRule.Assets.GetKLZCByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZCXQ([FromQuery] ZCDLEntity list)
        {
            try
            {

                DataTable SelectTable = await BusinessRule.Assets.GetZCXQ(list);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> SaveZC_ZCLYMX([FromBody] ListEntity list)
        {
            try
            {

                await BusinessRule.Assets.SaveZC_ZCLYMX(list);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCLY([FromBody] ZCLY zc)
        {
            try
            {
                if (zc.Zcly.ListID == "")
                {
                    zc.Zcly.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                    if (zc.Zcly.Djbh == "" || zc.Zcly.Djbh == null)
                    {
                        zc.Zcly.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcly.Bmdm, "LY");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcly.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCLY(zc.Zcly);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcly.ListID, zc.File, await GetICApiInfo()))
                    {
                        bool bsp = false;
                        JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                        spl.businessName = "zcly";
                        spl.businessId = zc.Zcly.ListID;
                        //spl.publicParamKey = "FEE_PROCESS";
                        spl.formCode = zc.File.code;

                        //spl.description.businessNo = zc.Zcly.ListID;
                        //spl.description.deptName = GetUserDeptName();
                        spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcly);
                        spl.callbackUrl = "";

                        bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                        if (bsp)
                        {
                            await BusinessRule.Assets.UpdateZC_ZCLY(zc.Zcly);
                        }

                    }
                }
                foreach (ZC_ZCLYMX mx in zc.mxlist)
                {
                    mx.LyID = zc.Zcly.ListID;
                    if (mx.ListID == "")
                    {
                        mx.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                        await BusinessRule.Assets.InsertZC_ZCLYMX(mx);
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_ZCLYMX(mx);
                    }
                }

                return Success(zc.Zcly.ListID);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCLY([FromBody] ZCLY zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcly.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCLY(zc.Zcly);
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_LYZT([FromBody] ListStatus zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_LYZT(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCLY(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCLY(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCLYByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCLYByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCLYMX(string Lyid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCLYMX(Lyid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCLYMXByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCLYMXByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCLYMX([FromBody] ZC_ZCLYMX zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCLYMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCLYMX([FromBody] ZC_ZCLYMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCLYMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCLYMX(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCLYMX(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        #endregion

        #region "资产变动"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBD([FromQuery] ZC_ZCBDQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCBD(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCBD([FromBody] ZCBD zc)
        {
            try
            {
                if (zc.Zcbd.ListID == "")
                {
                    zc.Zcbd.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                    if (zc.Zcbd.Djbh == "" || zc.Zcbd.Djbh == null)
                    {
                        zc.Zcbd.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zcbd.Bmdm, "BD");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcbd.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCBD(zc.Zcbd);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zcbd.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zcbd.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zcbd";
                            spl.businessId = zc.Zcbd.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.Zcbd.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zcbd);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCBD(zc.Zcbd);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCBD(zc.Zcbd);
                        }
                    }
                }
                foreach (ZC_ZCBDMX mx in zc.Mxlist)
                {
                    if (mx.ListID == "")
                    {
                        mx.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                        mx.Bdid = zc.Zcbd.ListID;
                        await BusinessRule.Assets.InsertZC_ZCBDMX(mx);
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_ZCBDMX(mx);
                    }
                }
                return Success(zc.Zcbd.ListID);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCBD([FromBody] ZCBD zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zcbd.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCBD(zc.Zcbd);
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCBD(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCBD(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBDByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCBDByID(Listid);
                //DataTable bdmx = await BusinessRule.Assets.GetZC_ZCBDMX(Listid);
                //ZCBD bd = new ZCBD();
                //bd.Zcbd = APICommond.DataTableToList.GetEntity<ZC_ZCBD>(SelectTable);
                //bd.Mxlist = APICommond.DataTableToList.GetEntities<ZC_ZCBDMX>(bdmx) as List<ZC_ZCBDMX>;
                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBDMXByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCBDMXByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBDMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCBDMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBDJL(string Zcdm)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCBDJL(Zcdm);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCBDMX([FromBody] ZC_ZCBDMX zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCBDMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCBDMX([FromBody] ZC_ZCBDMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCBDMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCBDMX(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCBDMX(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        #endregion

        #region "资产出借"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCJ([FromQuery] ZC_ZCCJQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCCJ(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCCJ([FromBody] ZCCJ zc)
        {
            try
            {
                if (zc.Zccj.ListID == "")
                {
                    zc.Zccj.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                    if (zc.Zccj.Djbh == "" || zc.Zccj.Djbh == null)
                    {
                        zc.Zccj.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Zccj.Bmdm, "CJ");
                    }
                    if (await JavaApi.UploadFileJavaAPI(zc.Zccj.ListID, zc.File, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_ZCCJ(zc.Zccj);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(zc.Zccj.ListID, zc.File, await GetICApiInfo()))
                    {
                        if (zc.Zccj.Zt == "0")
                        {
                            bool bsp = false;
                            JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                            spl.businessName = "zccj";
                            spl.businessId = zc.Zccj.ListID;
                            //spl.publicParamKey = "FEE_PROCESS";
                            spl.formCode = zc.File.code;

                            //spl.description.businessNo = zc.Zccj.ListID;
                            //spl.description.deptName = GetUserDeptName();
                            spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.Zccj);
                            spl.callbackUrl = "";

                            bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                            if (bsp)
                            {
                                await BusinessRule.Assets.UpdateZC_ZCCJ(zc.Zccj);
                            }
                        }
                        else
                        {
                            await BusinessRule.Assets.UpdateZC_ZCCJ(zc.Zccj);
                        }
                    }
                }
                foreach (ZC_ZCCJMX mx in zc.Mxlist)
                {
                    if (mx.ListID == "")
                    {
                        mx.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                        mx.Cjid = zc.Zccj.ListID;
                        await BusinessRule.Assets.InsertZC_ZCCJMX(mx);
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_ZCCJMX(mx);
                    }
                }
                return Success(zc.Zccj.ListID);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_CJ(ZC_CJEntity entity)
        {
            try
            {
                if (entity.zccj.ListID == "")
                {
                    if (entity.zccj.ListID == "")
                    {
                        entity.zccj.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                    if (entity.zccj.Djbh == "" || entity.zccj.Djbh == null)
                    {
                        entity.zccj.Djbh = await BusinessRule.Assets.CreateZCDM(entity.zccj.Bmdm, "CJ");
                    }

                    if (await JavaApi.UploadFileJavaAPI(entity.zccj.ListID, entity.FileCodes, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.InsertZC_CJ(entity);
                    }
                }
                else
                {
                    if (await JavaApi.UploadFileJavaAPI(entity.zccj.ListID, entity.FileCodes, await GetICApiInfo()))
                    {
                        await BusinessRule.Assets.UpdateZC_ZCCJ(entity.zccj);
                    }
                }
                foreach (ZC_ZCCJMX mx in entity.zccjmx)
                {
                    if (mx.ListID == "")
                    {
                        mx.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                        mx.Cjid = entity.zccj.ListID;
                        await BusinessRule.Assets.InsertZC_ZCCJMX(mx);
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_ZCCJMX(mx);
                    }
                }
                if (entity.zccj.Zt == "0")
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "jzccj";
                    spl.businessId = entity.zccj.ListID;
                    //spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = entity.FileCodes.formCode;

                    //spl.description.businessNo = entity.zccj.ListID;
                    //spl.description.deptName = GetUserDeptName();
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(entity.zccj);
                    spl.callbackUrl = "";

                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCCJ([FromBody] ZCCJ zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.Zccj.ListID, zc.File, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCCJ(zc.Zccj);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCCJ(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCCJ(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCJByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCCJByID(Listid);
                //DataTable mx = await BusinessRule.Assets.GetZC_ZCCJMX(Listid);
                //ZCCJ cj = new ZCCJ();
                //cj.Zccj = APICommond.DataTableToList.GetEntity<ZC_ZCCJ>(SelectTable);
                //cj.Mxlist = APICommond.DataTableToList.GetEntities<ZC_ZCCJMX>(mx) as List<ZC_ZCCJMX>;
                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCJMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCCJMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCJMXBYID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCCJMXBYID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_CJMMX([FromBody] ListEntity list)
        {
            try
            {

                await BusinessRule.Assets.InsertZC_CJMMX(list);


                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCCJMX([FromBody] ZC_ZCCJMX zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCCJMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCCJMX([FromBody] ZC_ZCCJMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCCJMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCCJMX(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCCJMX(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        #endregion

        #region "资产处置"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZCKP(string dwdm,string bmmc,string lbmc, string zcmc, string zcdm, int size=20, int current=1)
        {
            try
            {
                string orgs = await Getorg();
                (DataTable,int) table = await BusinessRule.Assets.GetZCKP(dwdm, orgs,bmmc,lbmc,zcmc,zcdm,size,current);
                Page page = new Page();
                page.records = table.Item1;
                page.total = table.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetJSFS()
        {
            try
            {
                DataTable table = await BusinessRule.Assets.GetJSFS();
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        //[AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCZ([FromQuery] ZC_ZCCZQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                entity.DepartID = await GetDepId();
                //entity.DepartID = "('1')";
                (IEnumerable<dynamic>, int) SelectTable = await BusinessRule.Assets.GetZC_ZCCZ(entity);
                List<string> list = new List<string>();
                foreach (dynamic item in SelectTable.Item1)
                {
                    string id = item.listid;
                    list.Add(id);
                }

                List<JavaApi.SPSDataItem> spitems = await JavaApi.GetSPStatusJavaAPI(entity.formcode, GetUserAccount(), list, await GetICApiInfo());
                foreach (dynamic item in SelectTable.Item1)
                {
                    string id = item.listid;
                    var spstatus = spitems.Where(ii => ii.businessId == id).FirstOrDefault();
                    string status = "unknown";
                    string zt= item.zt;
                    if (zt == "1")
                    {
                        status = "draft";

                    }
                    else if (zt == "2")
                    {
                        status = "uncheck";

                    }
                    else if (zt == "9")
                    {
                        status = "checking";

                    }
                    else if (zt == "3")
                    {
                        status = "checked";

                    }
                    else if (zt == "4")
                    {
                        status = "reject";

                    }
                    else if (zt == "5")
                    {
                        status = "invalid";

                    }
                    else if (zt == "6")
                    {
                        status = "changing";

                    }
                    else if (zt == "7")
                    {
                        status = "bfys";

                    }
                    else if (zt == "8")
                    {
                        status = "yys";

                    }
                    else
                    {
                        status = "unfilled";
                    }
                    item.panguData = GetPanGudData(spstatus, status);
                }

                Page pa = new Page();
                pa.records = SelectTable.Item1;
                pa.total = SelectTable.Item2;
                //_logger.Log(LogLevel.Info, Success(pa).ToJson());
                //return Success(pa);

                _logger.Log(LogLevel.Info, Success(pa).ToJson());
                return Success(pa);
               // return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCCZ([FromBody] ZC_CZEntity zc)
        {
            try
            {
                foreach (ZC_ZCCZMX mx in zc.zcczmx)
                {
                    DataTable table = await BusinessRule.Assets.GetKpBYdm(mx.zcdm);
                    if (table.Rows.Count > 0)
                    {
                        if (Convert.ToDecimal(table.Rows[0]["gdsl"]) != 1)
                        {
                            return Fail("资产代码为："+mx.zcdm+"的资产数量不是1，请拆分资产后再做资产处置！");
                        }
                    }
                }

                if (string.IsNullOrEmpty(zc.zccz.zt))
                {
                    zc.zccz.zt = "1";
                }
                if (zc.zccz.zt == "1")
                {
                    _logger.Log(LogLevel.Info, "这里");
                    if (string.IsNullOrEmpty(zc.zccz.listid))
                    {
                        zc.zccz.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                        if (string.IsNullOrEmpty(zc.zccz.djbh))
                        {
                            zc.zccz.djbh = await BusinessRule.Assets.CreateZCDM(zc.zccz.bmdm, "CZ");
                        }
                        if (await JavaApi.UploadFileJavaAPI(zc.zccz.listid, zc.FileCodes, await GetICApiInfo()))
                        {
                            await BusinessRule.Assets.InsertZC_ZCCZ(zc.zccz);
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(zc.zccz.djbh))
                        {
                            zc.zccz.djbh = await BusinessRule.Assets.CreateZCDM(zc.zccz.bmdm, "CZ");
                        }
                        if (await JavaApi.UploadFileJavaAPI(zc.zccz.listid, zc.FileCodes, await GetICApiInfo()))
                        {
                            await BusinessRule.Assets.UpdateZC_ZCCZ(zc.zccz);
                        }
                    }
                }

                else
                {
                    if (string.IsNullOrEmpty(zc.zccz.listid))
                    {
                        zc.zccz.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                    }
                        JavaApi.SPLEnt.Auditdescription _description = new JavaApi.SPLEnt.Auditdescription() { businessNo = zc.zccz.listid, amount = "", content = "资产处置" + zc.zccz.listid, deptName = GetUserDeptName() };
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "资产处置";
                    spl.businessId = zc.zccz.listid;
                    // spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = zc.FileCodes.formCode;
                    spl.description = _description.ToJson();


                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.zccz);
                    spl.callbackUrl = "http://ic-xmzc/netapi/Assets/UpdateStatus";
                    spl.callbackInterface = "/assets/dispose/apply?type=audit&taskid=${taskId}&listid=" + zc.zccz.listid;
                    spl.callbackView = "/assets/dispose/apply?type=see&listid="+zc.zccz.listid;
                    //JavaApi.SPLEnt spl = new JavaApi.SPLEnt("资产发布",id, filecodes.formCode, Newtonsoft.Json.JsonConvert.SerializeObject(str), "http://ic-xmzc/netapi/ProTZJH/UpdateStatus", url.Item1, url.Item2, _description);
                    //bool bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                    //if (!bsp)
                    string strInstanceId = await JavaApi.startInstanceJavaAPIStr(spl, await GetICApiInfo());
                    _logger.Log(LogLevel.Info, "审批流调用结束");
                    //ht.spl = strInstanceId;
                    if (strInstanceId.StartsWith("err"))
                    {
                        //await BusinessRule.Warning.Waring.UpdateSend(str, "-1");
                        return Fail("提交失败，启动工作流异常");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(zc.zccz.listid))
                        {
                            zc.zccz.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

                            if (zc.zccz.djbh == "" || zc.zccz.djbh == null)
                            {
                                zc.zccz.djbh = await BusinessRule.Assets.CreateZCDM(zc.zccz.bmdm, "CZ");
                            }
                            if (await JavaApi.UploadFileJavaAPI(zc.zccz.listid, zc.FileCodes, await GetICApiInfo()))
                            {
                                if (await JavaApi.UploadFileJavaAPI(zc.zccz.listid, zc.FileCodes, await GetICApiInfo()))
                                {
                                    await BusinessRule.Assets.InsertZC_ZCCZ(zc.zccz);
                                }
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(zc.zccz.djbh))
                            {
                                zc.zccz.djbh = await BusinessRule.Assets.CreateZCDM(zc.zccz.bmdm, "CZ");
                            }
                            if (await JavaApi.UploadFileJavaAPI(zc.zccz.listid, zc.FileCodes, await GetICApiInfo()))
                            {
                                await BusinessRule.Assets.UpdateZC_ZCCZ(zc.zccz);
                            }
                        }
                    }


                }
                await BusinessRule.Assets.DeleteZCCZMX(zc.zccz.listid);
                foreach (ZC_ZCCZMX mx in zc.zcczmx)
                {
                    if (string.IsNullOrEmpty(mx.listid))
                    {
                        mx.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                        mx.czid = zc.zccz.listid;
                        await BusinessRule.Assets.InsertZC_ZCCZMX(mx);
                    }
                    else
                    {
                        mx.czid = zc.zccz.listid;
                        await BusinessRule.Assets.UpdateZC_ZCCZMX(mx);
                    }
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        //[AllowAnonymous]
        //[HttpPost]
        public async Task<IActionResult> UpdateStatus(dynamic spjson)
        {
            //module，dealUser，approveStatus，businessName，businessId
            //dynamic spjson
            try
            {
                //_logger.Info(spjson.ToString());
                _logger.Debug(JsonConvert.SerializeObject(spjson));

                //{
                //    "businessId":"1403255058317729793",
                //    "businessName":"quotaDetailServiceImpl",
                //    "opinion":"合格，通过，批钱",
                //    "instanceId":352926,
                //    "taskId":352983
                //}
                //string taskId = spjson.taskId;
                //string businessName = spjson.businessName;
                //string instanceId = spjson.instanceId;

                string moduleid = spjson.module;
                string userid = spjson.dealUser;
                string approveStatus = spjson.approveStatus;//UNCHECK, CHECKING,REJECTED,INVALID,CHECKED

                //operation，值：AGREE（同意），REJECT（驳回），INVALID（作废），ACTIVATION（激活），CANCEL（撤销），RESTART（消审）
                string operation = spjson.operation;
                string businessId = spjson.businessId;
                string businessName = spjson.businessName;

                string additionInfo = spjson.additionInfo;

                //additionInfo： {
                //    sdje
                //    ywid
                //    tname
                //  }


                //这里加了一个审定金额



                if (string.IsNullOrEmpty(businessId))
                {
                    //return Fail("业务id不能为空");
                    return Json(new ResParameter { code = ResponseCode.fail, message = "业务id不能为空" });
                }

                //待提交，未审核，审核中 ，作废 ，已审核 ，驳回 ，撤销
                //DRAFT，UNCHECK, CHECKING,INVALID,CHECKED,RESTART
                string zt = "0";
                if (approveStatus == "DRAFT")
                {
                    zt = "1";
                }
                if (approveStatus == "UNCHECK")
                {
                    zt = "1";
                }
                if (approveStatus == "CHECKING")
                {
                    zt = "9";
                }
                if (approveStatus == "CHECKED")
                {
                    zt = "3";
                }
                if (approveStatus == "REJECT")
                {
                    zt = "4";
                }
                if (approveStatus == "INVALID")
                {
                    zt = "5";
                }
                if (approveStatus == "RESTART")
                {
                    zt = "1";
                }
                // string ztz = CProTZJHRule.GetXMGLSPZT(approveStatus);

                ListStatus status = new ListStatus();
                status.Zt = zt;
                status.ListID = businessId;

                await BusinessRule.Assets.UpdateZC_ZCCZZT(status);


                //if (operation == "RESTART")//消审以后
                //{
                //    ztz = "-1";//未提交的状态
                //}

                //  string strTname = businessName;

                //if (await BaseEditPower.GetEditPowerOpe(businessId, strTname, ztz))
                //{

                //}
                //else
                //{
                //    return Fail("请确认当前数据权限状态");
                //}

                // await BaseEditPower.SetStatus(businessId, strTname, ztz, GetUserName(), userid, CommonHelper.ParseDecimal(sdje));

                #region 加日志
                LogEntity logEntity = new LogEntity();
                logEntity.F_CategoryId = 3;
                logEntity.F_OperateTypeId = ((int)OperationType.Audit).ToString();
                logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Audit);
                logEntity.F_OperateAccount = ContextHelper.GetItem("userName") as string;
                logEntity.F_OperateUserId = ContextHelper.GetItem("userId") as string;
                logEntity.F_Module = Request.Path;
                logEntity.F_IPAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
                logEntity.F_ExecuteResult = -1;
                var timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
                logEntity.F_ExecuteResultJson = JsonConvert.SerializeObject(spjson, timeConverter);
                //添加日志
                await LogRule.Write(logEntity);
                #endregion


                //return Success("操作成功");
                return Json(new ResParameter { code = ResponseCode.success, message = "成功" });
            }
            catch (Exception ex)
            {
                return Json(new ResParameter { code = ResponseCode.fail, message = "操作失败" + ex.Message });
                //return Fail("操作失败："+ ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_CZ(ZC_CZEntity entity)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(entity.zccz.listid, entity.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_CZ(entity);
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCCZ([FromBody] ZC_ZCCZ zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCCZ(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCCZZT(ListStatus status)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCCZZT(status);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCCZ(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCCZ(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCZByID(string Listid)
        {
            try
            {
                dynamic dy=  new ExpandoObject();
                dy.zccz= await BusinessRule.Assets.GetZC_ZCCZByID(Listid);
                dy.zcczmx = await BusinessRule.Assets.GetZCCZMX(Listid);
                //DataTable mx = await BusinessRule.Assets.GetZC_ZCCZMX(Listid);
                //ZCCZ cz = new ZCCZ();
                //cz.Zccz = APICommond.DataTableToList.GetEntity<ZC_ZCCZ>(SelectTable);
                //cz.MxList = APICommond.DataTableToList.GetEntities<ZC_ZCCZMX>(mx) as List<ZC_ZCCZMX>;
                return Success(dy);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCCZMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCCZMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCCZMX([FromBody] ZC_ZCCZMX zc)
        {
            try
            {
                if (zc.listid == "")
                {
                    zc.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCCZMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCCZMX([FromBody] ZC_ZCCZMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCCZMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCCZMX(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCCZMX(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        #endregion

        #region "资产调拨"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCDB([FromQuery] ZC_ZCDBQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCDB(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZCDB([FromBody] ZC_DB db)
        {
            try
            {
                if (db.zcdb.ListID == "")
                {
                    db.zcdb.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (await JavaApi.UploadFileJavaAPI(db.zcdb.ListID, db.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZCDB(db);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCDB([FromBody] ZC_ZCDB zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (zc.Djbh == "" || zc.Djbh == null)
                {
                    zc.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Bmdm, "DB");
                }
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_ZCDB(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCDB([FromBody] ZC_ZCDB zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCDB(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZCDBZT(ListStatus status)
        {
            try
            {
                await BusinessRule.Assets.UpdateZCDBZT(status);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCDB(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCDB(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCDBByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCDBByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCDBMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCDBMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCDBMXBYid(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCDBMXBYid(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCDBMX([FromBody] ZC_ZCDBMX zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCDBMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCDBMX([FromBody] ZC_ZCDBMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCDBMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCDBMX(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCDBMX(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }



        #endregion

        #region"资产调拨确认"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCDBQr([FromQuery] ZC_DBQRQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCDBQr(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCDBPRMXR(string Listid)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCDBPRMXR(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCDBPRMXC(string Listid)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCDBPRMXC(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion

        #region "资产盘点"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPD([FromQuery] ZC_ZCPDQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCPD(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCPD([FromBody] ZC_ZCPD zc)
        {
            try
            {
                if (zc.ListID == "" || zc.ListID == null)
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (zc.Djbh == "" || zc.Djbh == null)
                {
                    zc.Djbh = await BusinessRule.Assets.CreateZCDM(zc.Bmdm, "PD");
                }
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_ZCPD(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCPD([FromBody] ZC_ZCPD zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_ZCPD(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCPDZT([FromBody] ListStatus status)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCPDZT(status);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCPD(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCPD(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPDByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPDByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPDMX(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPDMX(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPDMXByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCPDMXByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCPDMX([FromBody] ZC_ZCPDMX zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCPDMX(zc);

                return Success("成功");
            }

            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCPDMX([FromBody] ZC_ZCPDMX zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCPDMX(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCPDMX(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCPDMX(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }



        #endregion

        #region "资产盘点处理"

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCPDCL([FromQuery] ZC_ZCPDZCQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_ZCPDCL(entity);
                Page page = new Page();
                page.records = SelectTable.Item1;
                page.total = SelectTable.Item2;
                return Success(page);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCPDCL(string Listid, string Username, string Zt)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCPDCL(Listid, GetUserId(), Username, Zt);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        #endregion

        #region "经营系资产卡片"
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_JYXZC([FromQuery] ZC_JYXZCQuerry entity)
        {
            try
            {
                entity.UserID = GetUserId();
                //entity.DepartID = await GetDepId();a
                entity.DepartID = "('1')";
                (DataTable, int) SelectTable = await BusinessRule.Assets.GetZC_JYXZC(entity);
                Page pa = new Page();
                pa.records = SelectTable.Item1;
                pa.total = SelectTable.Item2;
                return Success(pa);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_JYXZC([FromBody] ZC_JYXZC zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.InsertZC_JYXZC(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_JYXZC([FromBody] ZC_JYXZC zc)
        {
            try
            {
                if (await JavaApi.UploadFileJavaAPI(zc.ListID, zc.FileCodes, await GetICApiInfo()))
                {
                    await BusinessRule.Assets.UpdateZC_JYXZC(zc);
                }

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }


        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_JYXZCByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_JYXZCByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        #endregion

        #region "资产部位"
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBW(string zcdm)
        {
            try
            {

                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCBW(zcdm);
                //Page pa = new Page();

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> InsertZC_ZCBW([FromBody] ZC_ZCBW zc)
        {
            try
            {
                if (zc.ListID == "")
                {
                    zc.ListID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
                }
                await BusinessRule.Assets.InsertZC_ZCBW(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateZC_ZCBW([FromBody] ZC_ZCBW zc)
        {
            try
            {
                await BusinessRule.Assets.UpdateZC_ZCBW(zc);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_ZCBW(string Listid)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_ZCBW(Listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCBWCByID(string Listid)
        {
            try
            {
                DataTable SelectTable = await BusinessRule.Assets.GetZC_ZCBWByID(Listid);

                return Success(SelectTable);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        #endregion

        #region “折旧”
        /// <summary>
        /// 根据单位和月份查询折旧信息
        /// </summary>
        /// <param name="Dwdm">单位代码</param>
        /// <param name="Yf">月份</param>
        /// <returns>资产折旧表</returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_ZCZJ(string Dwdm, string Yf)
        {

            try
            {
                DataTable table = await BusinessRule.Assets.GetZC_ZCZJ(Dwdm, Yf);
                return Success(table);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据单位和月份计算资产折旧
        /// </summary>
        /// <param name="Dwdm">单位代码</param>
        /// <param name="Yf">折旧月份</param>
        /// <param name="Userid">操作员编号</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> CreateZC_YZJ(string Dwdm, string Yf, string Userid)
        {
            try
            {
                string str = await BusinessRule.Assets.CreateZC_YZJ(Dwdm, Yf, Userid);
                if (str != "")
                {
                    return Fail(str);
                }
                else
                {
                    return Success("成功");
                }
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据单位和月份删除折旧
        /// </summary>
        /// <param name="Dwdm">单位代码</param>
        /// <param name="Yf">月份</param>
        /// <returns>执行结果</returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_YZJ(string Dwdm, string Yf)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_YZJ(Dwdm, Yf);
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        #endregion

        #region "地块"
        /// <summary>
        /// 获取组织代码
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetOrg()
        {
            try
            {
                // GetUserAccount();
                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                string org = await Getorg();

                Orgs orgs = new Orgs();
                DataTable table = await BusinessRule.Warning.Waring.GetOrg("0");

                orgs.org = "";
                orgs.orgName = "全部";

                DataRow[] rws = table.Select("org='" + org + "'");

                foreach (DataRow rw in rws)
                {
                    orgs.org = Convert.ToString(rw["org"]).Trim();
                    orgs.orgName = Convert.ToString(rw["orgname"]).Trim();
                    List<Orgs> listo = new List<Orgs>();
                    DataRow[] rows = table.Select("porg='" + org + "'");

                    foreach (DataRow row in rows)
                    {
                        Orgs ors = new Orgs();
                        ors.org = Convert.ToString(row["org"]).Trim();
                        ors.orgName = Convert.ToString(row["orgname"]).Trim();
                        listo.Add(ors);
                        List<Orgs> list = new List<Orgs>();
                        DataRow[] drs = table.Select("porg='" + Convert.ToString(row["org"]).Trim() + "'");
                        foreach (DataRow dr in drs)
                        {
                            Orgs os = new Orgs();
                            os.org = Convert.ToString(dr["org"]);
                            os.orgName = Convert.ToString(dr["orgname"]);
                            list.Add(os);
                            List<Orgs> ol = new List<Orgs>();
                            DataRow[] rs = table.Select("porg='" + Convert.ToString(dr["org"]) + "'");
                            foreach (DataRow r in rs)
                            {
                                Orgs o = new Orgs();
                                o.org = Convert.ToString(r["org"]);
                                o.orgName = Convert.ToString(r["orgname"]);
                                ol.Add(o);
                            }
                            os.orgs = ol;
                        }
                        ors.orgs = list;
                    }
                    orgs.orgs = listo;
                }


                return Success(orgs, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 获取单位属性
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetOrgsx()
        {
            try
            {

                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                DataTable table = await BusinessRule.Warning.Waring.GetDicInfo("orgsx");
                return Success(table, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 获取单位属性
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetOrgZC()
        {
            try
            {

                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                DataTable table = await BusinessRule.Warning.Waring.GetDicInfo("orgsx");
                table.Rows.RemoveAt(0);
                return Success(table, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 获取单位属性
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZCLB()
        {
            try
            {

                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                DataTable table = await BusinessRule.Warning.Waring.GetDicInfo("zclb");
                return Success(table, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }


        /// <summary>
        /// 获取单位属性
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZCL()
        {
            try
            {

                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                DataTable table = await BusinessRule.Warning.Waring.GetDicInfo("zclb");
                table.Rows.RemoveAt(0);
                return Success(table, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }

        /// <summary>
        ///地块分页接口
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_DK([FromQuery] ZC_DKQuerry querry)
        {
            try
            {
                querry.UserID = GetUserId();
                //querry.DepartID = await GetDepId("contract_permission");
                querry.DepartID = await Getorg();
                _logger.Info(querry.DepartID);
                (IEnumerable<dynamic>, int) SelectTable = await BusinessRule.Assets.GetZC_DK(querry);
                dynamic sum = await BusinessRule.Assets.GetZC_DKsum(querry);
                //querry.
                //List<string> list = new List<string>();
                //foreach (dynamic item in SelectTable.Item1)
                //{
                //    string id = item.id;
                //    list.Add(id);
                //}

                //List<JavaApi.SPSDataItem> spitems = await JavaApi.GetSPStatusJavaAPI(querry.FormCode, GetUserAccount(), list, await GetICApiInfo());
                //foreach (dynamic item in SelectTable.Item1)
                //{
                //    string id = item.id;
                //    var spstatus = spitems.Where(ii => ii.businessId == id).FirstOrDefault();
                //    string status = "unknown";
                //    if (item.status == "-1")
                //    {
                //        status = "draft";

                //    }
                //    else if (item.status == "0")
                //    {
                //        status = "uncheck";

                //    }
                //    else if (item.status == "1")
                //    {
                //        status = "checking";

                //    }
                //    else if (item.status == "2")
                //    {
                //        status = "checked";

                //    }
                //    else if (item.status == "3")
                //    {
                //        status = "reject";

                //    }
                //    else if (item.status == "4")
                //    {
                //        status = "invalid";

                //    }
                //    else
                //    {
                //        status = "unfilled";
                //    }
                //    item.panguData = GetPanGudData(spstatus, status);
                //}

                Pagex pa = new Pagex();
                pa.records = SelectTable.Item1;
                pa.total = SelectTable.Item2;
                pa.sum = sum;
                //_logger.Log(LogLevel.Info, Success(pa).ToJson());
                //return Success(pa);

                _logger.Log(LogLevel.Info, Success(pa).ToJson());
                return Success(pa);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 保存、提交地块接口
        /// </summary>
        /// <param name="zc"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> SaveZC_DK([FromBody] DK zc)
        {
            try
            {
                //    HT_SubmitHT htsubmit = new HT_SubmitHT();
                //    htsubmit.businessNo = ht.fkhtxx.htbh;
                //    htsubmit.amount = ht.fkhtxx.htje.ToString();
                //    htsubmit.deptName = ht.fkhtxx.sqbm;
                //    htsubmit.content = ht.fkhtxx.htmc;
                //  await JavaApi.UploadFileJavaAPI(ht.fkhtxx.htbh, ht.File, await GetICApiInfo());
                _logger.Info(zc.ToJson().ToString());
                if (string.IsNullOrEmpty(zc.dk.zt))
                {
                    zc.dk.zt = "1";
                }
                _logger.Info("1");
                if (zc.dk.zt == "1")
                {
                    //if (await JavaApi.UploadFileJavaAPI(zc.dk.listid, zc.File, await GetICApiInfo()))
                    //{
                    // ZC_DK zcdk = new ZC_DK();

                    zc.dk.kymj = 0;
                    zc.dk.czmj = 0;
                    zc.dk.jzmj = 0;
                    zc.dk.yz = 0;
                    _logger.Info("2");
                    if (zc.dkzc != null)
                    {
                        foreach (DKZC dk in zc.dkzc)
                        {
                            if (dk.kymj!=null)
                            {
                                zc.dk.kymj += dk.kymj;
                            }
                            if (dk.tradearea != null)
                            {
                                zc.dk.czmj += dk.tradearea;
                            }
                            if (dk.jzmj != null)
                            {
                                zc.dk.jzmj += dk.jzmj;
                            }
                            if (dk.yz != null)
                            {
                                zc.dk.yz += dk.yz;
                            }
                            //zc.dk.zcsl++;
                        }
                        zc.dk.zcsl = zc.dkzc.Count;
                    }

                    //if (zc.dk.jzmj > 0)
                    //{
                    //    zc.dk.xzl = zc.dk.kymj / zc.dk.jzmj * 100;
                    //}
                    //else
                    //{
                    //    zc.dk.xzl = 0;
                    //}
                    _logger.Info("3");
                    if (string.IsNullOrEmpty(zc.dk.listid))
                    {
                        _logger.Info("4");
                        zc.dk.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffff");
                        await BusinessRule.Assets.InsertZC_DK(zc.dk);
                    }
                    else
                    {
                        _logger.Info("5");
                        await BusinessRule.Assets.UpdateZC_DK(zc.dk);
                    }
                    //}
                }
                else
                {
                    bool bsp = false;
                    JavaApi.SPLEnt spl = new JavaApi.SPLEnt();
                    spl.businessName = "地块管理";
                    spl.businessId = zc.dk.listid;
                    // spl.publicParamKey = "FEE_PROCESS";
                    spl.formCode = "";

                    JavaApi.SPLEnt.Auditdescription _description = new JavaApi.SPLEnt.Auditdescription() { businessNo = zc.dk.listid, amount = zc.dk.kymj.ToString(), content = zc.dk.dkmc, deptName = zc.dk.dwmc };
                    // spl.description = Newtonsoft.Json.JsonConvert.SerializeObject(htsubmit);
                    spl.description = _description.ToJson();
                    spl.additionInfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(zc.dk);
                    spl.callbackUrl = "http://ic-xmzc/netapi/Assets/UpdateDKStatus";
                    spl.callbackInterface = "";

                    spl.callbackInterface = "/contract-rule/payment/purchase-audit/audit/${taskId}/" + zc.dk.listid + " ";




                    bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                    zc.dk.zt = "2";

                    //string url = BaseEditPower.GetSPDetailUrl(BaseEditPower.TableName.合同.ToString(), ht.fkhtxx.htbh);
                    // JavaApi.SPLEnt spl = new JavaApi.SPLEnt("FKHTsubmit", ht.fkhtxx.htbh, ht.File.formCode, Newtonsoft.Json.JsonConvert.SerializeObject(ht.fkhtxx), "http://ic-xmzc/netapi/HT/SubmitHT_FKHT");
                    //bsp = await JavaApi.startInstanceJavaAPI(spl, await GetICApiInfo());
                    if (!bsp)
                    {
                        zc.dk.zt = "1";

                        await BusinessRule.Assets.UpdateZC_DK(zc.dk);
                        return Fail("提交失败，启动工作流异常");
                    }
                    else
                    {
                        await BusinessRule.Assets.UpdateZC_DK(zc.dk);

                        //return Success("成功");
                    }
                }
                await BusinessRule.Assets.DeleteZC_DKZC(zc.dk.listid);
                if (zc.dkzc != null)
                {
                    foreach (DKZC dk in zc.dkzc)
                    {
                        dk.dkid = zc.dk.listid;
                        dk.listid = DateTime.Now.ToString("yyyyMMddHHmmssfffff");
                        await BusinessRule.Assets.InsertZC_DKZC(dk);

                    }
                }
                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 审批回调接口
        /// </summary>
        /// <param name="spjson"></param>
        /// <returns></returns>
        [HttpPost]
        //[AllowAnonymous]
        //[HttpPost]
        public async Task<IActionResult> UpdateDKStatus(dynamic spjson)
        {
            //module，dealUser，approveStatus，businessName，businessId
            //dynamic spjson
            try
            {
                //_logger.Info(spjson.ToString());
                _logger.Debug(JsonConvert.SerializeObject(spjson));

                //{
                //    "businessId":"1403255058317729793",
                //    "businessName":"quotaDetailServiceImpl",
                //    "opinion":"合格，通过，批钱",
                //    "instanceId":352926,
                //    "taskId":352983
                //}
                //string taskId = spjson.taskId;
                //string businessName = spjson.businessName;
                //string instanceId = spjson.instanceId;

                string moduleid = spjson.module;
                string userid = spjson.dealUser;
                string approveStatus = spjson.approveStatus;//UNCHECK, CHECKING,REJECTED,INVALID,CHECKED

                //operation，值：AGREE（同意），REJECT（驳回），INVALID（作废），ACTIVATION（激活），CANCEL（撤销），RESTART（消审）
                string operation = spjson.operation;
                string businessId = spjson.businessId;
                string businessName = spjson.businessName;

                string additionInfo = spjson.additionInfo;

                //additionInfo： {
                //    sdje
                //    ywid
                //    tname
                //  }


                //这里加了一个审定金额



                if (string.IsNullOrEmpty(businessId))
                {
                    //return Fail("业务id不能为空");
                    return Json(new ResParameter { code = ResponseCode.fail, message = "业务id不能为空" });
                }

                //待提交，未审核，审核中 ，作废 ，已审核 ，驳回 ，撤销
                //DRAFT，UNCHECK, CHECKING,INVALID,CHECKED,RESTART
                string zt = "0";
                if (approveStatus == "DRAFT")
                {
                    zt = "1";
                }
                if (approveStatus == "UNCHECK")
                {
                    zt = "1";
                }
                if (approveStatus == "CHECKING")
                {
                    zt = "9";
                }
                if (approveStatus == "CHECKED")
                {
                    zt = "3";
                }
                if (approveStatus == "REJECT")
                {
                    zt = "4";
                }
                if (approveStatus == "INVALID")
                {
                    zt = "5";
                }
                if (approveStatus == "RESTART")
                {
                    zt = "1";
                }


                // string ztz = CProTZJHRule.GetXMGLSPZT(approveStatus);



                await BusinessRule.Assets.UpdateDKstatus(businessId, zt);


                //if (operation == "RESTART")//消审以后
                //{
                //    ztz = "-1";//未提交的状态
                //}

                //  string strTname = businessName;

                //if (await BaseEditPower.GetEditPowerOpe(businessId, strTname, ztz))
                //{

                //}
                //else
                //{
                //    return Fail("请确认当前数据权限状态");
                //}

                // await BaseEditPower.SetStatus(businessId, strTname, ztz, GetUserName(), userid, CommonHelper.ParseDecimal(sdje));

                #region 加日志
                LogEntity logEntity = new LogEntity();
                logEntity.F_CategoryId = 3;
                logEntity.F_OperateTypeId = ((int)OperationType.Audit).ToString();
                logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Audit);
                logEntity.F_OperateAccount = ContextHelper.GetItem("userName") as string;
                logEntity.F_OperateUserId = ContextHelper.GetItem("userId") as string;
                logEntity.F_Module = Request.Path;
                logEntity.F_IPAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
                logEntity.F_ExecuteResult = -1;
                var timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
                logEntity.F_ExecuteResultJson = JsonConvert.SerializeObject(spjson, timeConverter);
                //添加日志
                await LogRule.Write(logEntity);
                #endregion


                //return Success("操作成功");
                return Json(new ResParameter { code = ResponseCode.success, message = "成功" });
            }
            catch (Exception ex)
            {
                return Json(new ResParameter { code = ResponseCode.fail, message = "操作失败" + ex.Message });
                //return Fail("操作失败："+ ex.Message);
            }
        }

        /// <summary>
        /// 删除地块接口
        /// </summary>
        /// <param name="Listid"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> DeleteZC_DK(ZC_DK dk)
        {
            try
            {
                await BusinessRule.Assets.DeleteZC_DK(dk.listid);

                return Success("成功");
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }

        /// <summary>
        /// 地块获取详情接口
        /// </summary>
        /// <param name="listid"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetZC_DKCByID(string listid)
        {
            try
            {
                BackDK dk = new BackDK();
                DataTable dt = await BusinessRule.Assets.GetZC_DKByID(listid);
                DataTable table = await BusinessRule.Assets.GetZC_DKZCByID(listid);

                dk.dk = APICommond.DataToEntity.DataTableToEntity<ZC_K>(dt);
                List<Asset> list = APICommond.DataToEntity.DataTableToEntityList<Asset>(table) as List<Asset>;
                dk.dkzc = list;

                return Success(dk);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }

        }
        #endregion

        #region "资产"

        /// <summary>
        /// 选择资产接口
        /// </summary>
        /// <param name="org">单位代码</param>
        /// <param name="type">类型</param>
        /// <param name="zcmc">资产名称</param>
        /// <param name="zcbm">资产代码</param>
        /// <param name="zclb">资产类别</param>
        /// <param name="zcxz">资产性质</param>
        /// <param name="zylx">资产来源</param>
        /// <param name="zt">状态</param>
        /// <param name="zkdm">使用状态</param>
        /// <param name="dwlx">单位类型</param>
        /// <param name="dwsx">单位属性</param>
        /// <param name="cyjg">产业结构</param>
        /// <param name="xzls">闲置率开始</param>
        /// <param name="xzle">闲置率开始</param>
        /// <param name="current">第几页</param>
        /// <param name="size">每页行数</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetAssets([FromQuery]AssetQuerry querry)
        {
            try
            {

                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);

                querry.zclb = "房屋及建筑物";
                string orgs = await Getorg();
                if (string.IsNullOrEmpty(querry.org))
                {

                    querry.org = orgs;
                }


                if (!querry.org.Contains(orgs))
                {
                    querry.org = orgs;
                }

                _logger.Log(LogLevel.Info, querry.org);

                _logger.Log(LogLevel.Info, querry.org);
                (DataTable, int) SelectTable = await BusinessRule.Warning.Waring.GetAssetsx(querry.org, querry.type, querry.zcmc, querry.zcbm, querry.zclb, querry.zylx, querry.zcxz, querry.zt, querry.zkdm, querry.dwlx, querry.dwsx, querry.cyjg, 0, 0, querry.current, querry.size);
                //DataTable dataTable = await BusinessRule.Warning.Waring.GetAssetsSum(org, type, zcmc, zcbm, zclb, zylx, zcxz, zt, zkdm, dwlx, dwsx, cyjg);
                //DataTable table = await BusinessRule.Warning.Waring.GetWXZC(org, zcmc, zcbm, zclb, zcxz, zkdm, dwlx, dwsx);
                //int count = SelectTable.Item2;
                //decimal summj = 0;
                //decimal sumktmj = 0;
                //decimal sumyz = 0;
                //decimal htsl = 0;
                //decimal htje = 0;
                //foreach (DataRow row in dataTable.Rows)
                //{
                //    if (type == "1")
                //    {
                //        if (row["jzmj"] != DBNull.Value)
                //        {
                //            summj = summj + Convert.ToDecimal(row["jzmj"]);
                //        }
                //    }
                //    else
                //    {
                //        if (row["zymj"] != DBNull.Value)
                //        {
                //            summj = summj + Convert.ToDecimal(row["zymj"]);
                //        }
                //    }
                //    if (row["kymj"] != DBNull.Value)
                //    {
                //        sumktmj = sumktmj + Convert.ToDecimal(row["kymj"]);
                //    }
                //    if (row["yz"] != DBNull.Value)
                //    {
                //        sumyz = sumyz + Convert.ToDecimal(row["yz"]);
                //    }
                //    htsl = Convert.ToDecimal(row["htsl"]);
                //    htje = Convert.ToDecimal(row["htje"]);
                //}
                //decimal wyz = 0;
                //foreach (DataRow row1 in table.Rows)
                //{
                //    wyz = wyz + Convert.ToDecimal(row1["yz"]);
                //}
                AssetsSum sum = new AssetsSum();
                sum.count = 0;
                sum.kymj = 0;
                sum.total = SelectTable.Item2;
                sum.yz = 0;
                sum.zmj = 0;
                sum.htsl = 0;
                sum.htje = 0;
                sum.wyz = 0;
                sum.zyz = 0;
                _logger.Log(LogLevel.Info, querry.org);
                List<Asset> list = new List<Asset>();
                list = DataToEntity.DataTableToEntityList<Asset>(SelectTable.Item1) as List<Asset>;
                sum.records = list;



                _logger.Log(LogLevel.Info, Success(sum).ToJson());
                return Success(sum);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 根据选择的资产代码返回列表
        /// </summary>
        /// <param name="zcdm">资产代码数组</param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> GetAssetsByDM([FromBody] string[] zcdm)
        {
            try
            {
                string[] dm = zcdm;
                string dms = "";
                foreach (string s in dm)
                {
                    dms += "'" + s + "',";
                }
                dms = dms.Substring(0, dms.Length - 1);
                DataTable dt = await BusinessRule.Warning.Waring.GetAssetsByDM(dms);
                return Success(dt);
            }
            catch (Exception e)
            {
                return Fail(e.Message);
            }
        }
        /// <summary>
        /// 根据资产代码获取资产详情
        /// </summary>
        /// <param name="zcbm"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetAssetsInfo(string zcbm)
        {
            try
            {
                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                AssetsInfo info = new AssetsInfo();
                DataTable dataTable = await BusinessRule.Warning.Waring.GetAssetsInfo(zcbm);
                DataTable zf = await BusinessRule.Warning.Waring.GetAssetsContractInfo(zcbm);
                info.asset = DataToEntity.DataTableToEntity<Asset>(dataTable);
                DataView view = zf.DefaultView;
                view.RowFilter = "htzt='当前合同'";
                List<BusinessEntity.Warning.Contract> listc = new List<BusinessEntity.Warning.Contract>();
                listc = DataToEntity.DataTableToEntityList<BusinessEntity.Warning.Contract>(view.ToTable()) as List<BusinessEntity.Warning.Contract>;
                info.contracts = listc;
                List<BusinessEntity.Warning.Contract> listh = new List<BusinessEntity.Warning.Contract>();
                DataView view1 = zf.DefaultView;
                view1.RowFilter = "htzt='历史合同'";
                listh = DataToEntity.DataTableToEntityList<BusinessEntity.Warning.Contract>(view1.ToTable()) as List<BusinessEntity.Warning.Contract>;
                info.contract_historys = listh;

                Contractsum contractsum = new Contractsum();
                DataTable htmj = await BusinessRule.Warning.Waring.GetHTMJ(zcbm);
                if (htmj.Rows.Count > 0)
                {
                    contractsum.czmj += Convert.ToDecimal(htmj.Rows[0]["tradearea"]);
                }
                if (listc != null)
                {
                    contractsum.count = listc.Count;
                    foreach (BusinessEntity.Warning.Contract c in listc)
                    {
                        // contractsum.czmj += Convert.ToDecimal(c.zlmj);
                        contractsum.zje += Convert.ToDecimal(c.ttlamt);
                    }
                }
                info.contractsum = contractsum;
                ContractsumH sumh = new ContractsumH();
                DataTable htmjh = await BusinessRule.Warning.Waring.GetHTMJW(zcbm);
                if (htmjh.Rows.Count > 0)
                {
                    sumh.czmj += Convert.ToDecimal(htmjh.Rows[0]["tradearea"]);
                }
                if (listh != null)
                {
                    sumh.count = listh.Count;
                    foreach (BusinessEntity.Warning.Contract c in listh)
                    {
                        //sumh.czmj += Convert.ToDecimal(c.zlmj);
                        sumh.zje += Convert.ToDecimal(c.ttlamt);
                    }
                }
                info.contractsum_historys = sumh;
                return Success(info);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }


        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetBuildingByCode(string zcbm)
        {
            try
            {
                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);
                Building buid = new Building();
                DataTable dataTable = await BusinessRule.Warning.Waring.GetBuildingByCode(zcbm);
                buid = DataToEntity.DataTableToEntity<Building>(dataTable);
                return Success(buid, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<IActionResult> GetSYZK()
        {
            try
            {
                _logger.Log(LogLevel.Info, this.Url.Action() + this.Request.QueryString.Value);

                DataTable dataTable = await BusinessRule.Warning.U8Data.GetSYZK();

                return Success(dataTable, true);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Info, ex.Message);
                return Fail(ex.Message);
            }
        }
        #endregion
    }
}
